﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cesave.Domain.PermisosModule.Entities;
using Cesave.Domain.Core.Specification;
using Cesave.Domain.PermisosModule.Resources;

namespace Cesave.Domain.PermisosModule.Contracts.FoliosPermisos
{
	/// <summary>
	/// 
	/// </summary>
	public class FoliosPermisoByJuntaAndCicloAndAreaSpecification
		: Specification<FoliosPermiso>
	{
		#region Private properties

		/// <summary>
		/// 
		/// </summary>
		private Guid _juntaGuid = default(Guid);

		/// <summary>
		/// 
		/// </summary>
		private Guid _cicloGuid = default(Guid);

		/// <summary>
		/// 
		/// </summary>
		private Guid _areaGuid = default(Guid);

		#endregion

		#region Constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="juntaGuid"></param>
		/// <param name="cicloGuid"></param>
		/// <param name="areaGuid"></param>
		public FoliosPermisoByJuntaAndCicloAndAreaSpecification(
			Guid juntaGuid,
			Guid cicloGuid,
			Guid areaGuid)
		{
			if (juntaGuid == Guid.Empty)
				throw new ArgumentException(Messages.exception_InvalidArgument, "juntaGuid");
			if (cicloGuid == Guid.Empty)
				throw new ArgumentException(Messages.exception_InvalidArgument, "cicloGuid");
			if (areaGuid == Guid.Empty)
				throw new ArgumentException(Messages.exception_InvalidArgument, "areaGuid");
			_juntaGuid = juntaGuid;
			_cicloGuid = cicloGuid;
			_areaGuid = areaGuid;
		}

		#endregion

		#region Specification overrides

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override System.Linq.Expressions.Expression<Func<FoliosPermiso, bool>> SatisfiedBy()
		{
			Specification<FoliosPermiso> specification = new TrueSpecification<FoliosPermiso>();
			specification &= new DirectSpecification<FoliosPermiso>(f => f.JuntaGuid == _juntaGuid);
			specification &= new DirectSpecification<FoliosPermiso>(f => f.CicloGuid == _cicloGuid);
			specification &= new DirectSpecification<FoliosPermiso>(f => f.AreaGuid == _areaGuid);
			return specification.SatisfiedBy();
		}

		#endregion
	}
}